package com.ruoyi.project.hcy.administrations.controller;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.hcy.administrations.domain.Crew;
import com.ruoyi.project.hcy.administrations.domain.Invite;
import com.ruoyi.project.hcy.administrations.service.IInviteService;
import com.ruoyi.project.system.post.domain.Post;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ClassName InviteController
 * @Author 金刚芭比
 * @Date 2020/9/17 15:19
 * @Version 1.0
 */
@Controller
@RequestMapping("/hcy/invite")
public class InviteController extends BaseController {
    @Autowired
    private IInviteService inviteService;


    private String prefix="hcy/administrations";
    @GetMapping
    public String toInvite(){
        return prefix + "/invite";
    }
    @RequiresPermissions("hcy:invite:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list() {
        startPage();
        List<Invite> list = inviteService.selectInviteAll("待审批..");
        return getDataTable(list);
    }
    @GetMapping("/add")
    public String toAddInvite(){
        return prefix + "/addinvite";
    }
    @RequiresPermissions("hcy:invite:add")
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addInvite(@Validated Invite invite)
    {
        return toAjax(inviteService.insertInvite(invite));
    }


}
